# Memgraph

## Setup

### Install LangChain dependencies

Install the dependencies needed for Memgraph:

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/openai neo4j-driver @langchain/community
```

### Install Memgraph

Memgraph bundles the database along with various analytical tools into distinct
Docker images. If you're new to Memgraph or you're in a developing stage, we
recommend using the `memgraph-platform` image. Besides the database, it also
includes all the tools you might need to analyze your data, such as command-line
interface [mgconsole](https://memgraph.com/docs/getting-started/cli), web
interface [Memgraph Lab](https://memgraph.com/docs/data-visualization) and a
complete set of algorithms within a
[MAGE](https://memgraph.com/docs/advanced-algorithms) library.

With the Docker running in the background, run the following command in the
console:

```bash
docker run -p 7687:7687 -p 7444:7444 -p 3000:3000 --name memgraph memgraph/memgraph-platform
```

For other options of installation, check the [Getting started guide](https://memgraph.com/docs/getting-started).

## Usage

The example below shows how to instantiate Memgraph graph, create a small database and retrieve information from the graph by generating Cypher query language statements using `GraphCypherQAChain`.

import CodeBlock from "@theme/CodeBlock";
import GraphDBExample from "@examples/chains/memgraph.ts";

<CodeBlock language="typescript">{GraphDBExample}</CodeBlock>

# Disclaimer ⚠️

_Security note_: Make sure that the database connection uses credentials that
are narrowly-scoped to only include necessary permissions. Failure to do so may
result in data corruption or loss, since the calling code may attempt commands
that would result in deletion, mutation of data if appropriately prompted or
reading sensitive data if such data is present in the database. The best way to
guard against such negative outcomes is to (as appropriate) limit the
permissions granted to the credentials used with this tool. For example,
[creating read only
users](https://memgraph.com/docs/configuration/security#role-based-access-control-enterprise)
for the database is a good way to ensure that the calling code cannot mutate or
delete data. See the [security page](/docs/security) for more information.
